<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">添加学员到班级</h3>
    </div>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        {{ csrf_field() }}
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="name">学生名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="name" id="child_search" placeholder="学生姓名">
                    <input type="hidden" id="c_id" name="c_id">
                </div>
            </div>
        </div>
        <!-- /.box-body -->

        <div class="box-footer">
            <button type="button" class="btn btn-primary" data-url="{{ url('admin/child/classes', $id) }}" data-type="POST" onclick="subAction(this)">提 交</button>
            <button type="button" class="btn btn-default" data-url="{{ url('admin/classes') }}" onclick="jumpfun(this)">返 回</button>
        </div>
    </form>
</div>
<script>
    $(function () {
        //学生自动搜索
        var children = [];
        $.get("/admin/child/find",function(data){
            var obj = JSON.parse(data);
            for (x in obj){
                children.push(obj[x]);
            }
        });
        $( "#child_search" ).autocomplete({
            source: children,
            minLength: 1,
            delay: 500,
            max: 10,
            select: function (event, ui) {
                $("#c_id").val(ui.item.id);
            }
        });
    })
</script>